import { $delete, $get, $put, $post } from '@js/authRequest'

// 删除送达
export async function delServiceRequest (id) {
  const res = await $delete(`/api/xapc/deliver/${id}`)
  if (res.status !== 1) {
    throw new Error(res.message)
  }
  return res.data
}

// 获取请求内容
export async function getContentRequest (data) {
  const res = await $get('/api/xapc/deliver/getDeliverContent', data)
  if (res.status !== 1) {
    throw new Error(res.message)
  }
  return res.data
}

// 更新送达数据
export async function updateModalRequest (d) {
  const id = d.id
  delete d.id
  delete d.org_type
  const res = await $put(`/api/xapc/deliver/${id}`, d)
  if (res.status !== 1) {
    throw new Error(res.message)
  }
  return res.data
}

// 新增送达数据
export async function addModalRequest (d) {
  delete d.org_type
  const res = await $post('/api/xapc/deliver', d)
  if (res.status !== 1) {
    throw new Error(res.message)
  }
  return res.data
}
